]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
main: add logStackTrace(), for debugging
authorDan Winship <danw@gnome.org>
Wed, 20 Jul 2011 17:45:31 +0000 (13:45 -0400)
committerDan Winship <danw@gnome.org>
Wed, 20 Jul 2011 19:45:58 +0000 (15:45 -0400)
Add Main.logStackTrace(), to print a (javascript) stack trace, which
is often useful when debugging.

https://bugzilla.gnome.org/show_bug.cgi?id=654987

js/ui/main.js

index 6cb58fd41eb3b4c8cf754bcb5051d44c9cc482df..47f6af2cd1fd6f343d51578b85f1d2c6114b6584 100644 (file)
@@ -486,6 +486,18 @@ function _getAndClearErrorStack() {
     return errors;
 }
 
+function logStackTrace(msg) {
+    try {
+        throw new Error();
+    } catch (e) {
+        // e.stack must have at least two lines, with the first being
+        // logStackTrace() (which we strip off), and the second being
+        // our caller.
+        let trace = e.stack.substr(e.stack.indexOf('\n') + 1);
+        log(msg ? (msg + '\n' + trace) : trace);
+    }
+}
+
 function isWindowActorDisplayedOnWorkspace(win, workspaceIndex) {
     return win.get_workspace() == workspaceIndex ||
         (win.get_meta_window() && win.get_meta_window().is_on_all_workspaces());